package com.kayak.tg.client.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.kayak.distribute.service.IService1;
import com.kayak.distribute.service.IService2;
import com.kayak.distribute.service.IService3;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName TestController
 * @Dsecription TODO
 * @Auth tinxi
 * @DATAE 2019/3/26 14:32
 */
@RestController
public class MyController {

	/**
	 * 硬编码注册服务方式
	 */
	@Reference(version = "1.0.0",group = "1")
	IService1 service1;
	@Reference(version = "1.0.0",group = "2")
	IService2 service2;
	@Reference(version = "1.0.0",group = "3")
	IService3 service3;

	@RequestMapping("/testService")
	public String testService(@RequestParam("type")String type) {
		if ("1".equals(type)) {
			service1.rpcInvoke();
		} else if ("2".equals(type)) {
			service2.rpcInvoke();
		} else {
			service3.rpcInvoke();
		}

		return "success";
		// return null;
	}

	@RequestMapping("/test11")
	public String test(@RequestParam("type")String type) {
		System.out.println(123);
		// DubboFactory.init("Iservice12", "127.0.0.1", "2", "1.0.0");
		// DubboFactory.invoke("test", "hello,world");
		return "success123";
	}

}
